package com.fenghongzhang.day006anim;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class Main2Activity extends AppCompatActivity {
    private Button start;
    private Button stop;
    private ImageView img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);


        start = (Button) findViewById(R.id.start);
        stop = (Button) findViewById(R.id.stop);
        img = (ImageView) findViewById(R.id.img);

    }


    public void start(View view) {

        img.setImageResource(R.drawable.anim);
        AnimationDrawable drawable = (AnimationDrawable) img.getDrawable();
        drawable.start();
    }
    public void stop(View view) {
        AnimationDrawable drawable = (AnimationDrawable) img.getDrawable();
        drawable.stop();
    }

}
